#ifndef _BASIC_FUNC_
#define _BASIC_FUNC_

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>

#define STRTOK_AND_CHECK(symbol,in_p,out_p) ((out_p=strtok(in_p,symbol))!=NULL)	//For separating string.

//TIME
#define GET_TIME_I64() time(NULL)	//for get now time
void SecToDate(__int64 nSec, int*Y = NULL, int*M = NULL, int*D = NULL, int*h = NULL, int*m = NULL, int*s = NULL);	//Return int64 sec's date time.

//LOG FILE
class CLOG_FILE
{
protected:
	FILE *m_fp;
	char m_FileName[32];
	char m_nNowDay;
	char m_FileMode[16];
public:
	CLOG_FILE(){
		m_fp = NULL;
		memset(m_FileName, 0, sizeof(m_FileName));
		memset(m_FileMode, 0, sizeof(m_FileMode));
		m_nNowDay = -1;
	};
	~CLOG_FILE(){
		if(m_fp) {
			fclose(m_fp);
			m_fp = NULL;
		}
	}
	bool DateLogFileOpen(char *pFileName, const char *mode );	//open file with "FileName_Y_M_D".
	bool WriteLogWithDate(char *pStr);	//Write log with date.
};

#endif //#ifndef _TIME_FUNC_